package com.echat.serviceapigateway.security.tool;

import com.echat.commonlib.util.SpringContextUtil;
import com.echat.serviceapigateway.security.cache.AccessCacher;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.StringRedisTemplate;

/**
 * Created by chenmohan on 2018/10/12
 *
 * @description 对common-lib包下的SpringContextUtil工具类封装,暴露指定的bean和bean的一些方法
 */
public class SpringUtil {

    public static StringRedisTemplate getStringRedisTemplate(){
        return (StringRedisTemplate) SpringContextUtil.getBean(StringRedisTemplate.class);
    }

    public static AccessCacher getAccessCacher(){
        return (AccessCacher) SpringContextUtil.getBean(AccessCacher.class);
    }

    public static void clearUserAccessCahcer(Long userId){
        ((AccessCacher) SpringContextUtil.getBean(AccessCacher.class)).clearUserAccessCache(userId);
    }

}
